from keras import losses
import tensorflow as tf
from keras import backend as K
import numpy as np

def MyHinge(y_true,y_pred):
    return K.maximum( 1-K.sum(y_true*y_pred),  0. )


true = tf.constant( np.array([0.,1.,0.]),dtype = tf.float32 )
pred = tf.constant( np.array([1.,0.,0.]),dtype = tf.float32 )


with tf.Session() as sess:
    print(MyHinge(true,pred).eval())